const Router = require('koa-router')
const router = new Router({
    prefix: "/api/admin/order_record"
})

const OrderRecord = require('../../models/order_record')
const {
    Success
} = require('../../utils/response')

router.get('/order_record', async (ctx) => {
    let user_id = ctx.request.query.user_id
    let orderlist;
    if (user_id) {
        orderlist = await OrderRecord.findAll({
            where: {
                user_id
            }
        })
    } else {
        orderlist = await Order.findAll()
    }

    ctx.body = Success(orderlist)
})

module.exports = router